<head>

	<script type="text/javascript" src="scripts/jquery/jquery-1.7.1.js"></script>
	<script>

	</script>
</head>
<html>

<body>

	<label>名称</label> <input type="text" id="name" disabled="disabled" /><br>
	<label>时间</label>
	<select id="time">
		<option value="">--请选择--</option>
	</select><br>
	<label>文件类型</label>
	<select name="fangyuanEntity.fyHxCode" id="type" class="ui_select01">
		<option value="">--请选择--</option>
		<option value="76">项目建议书</option>
		<option value="10">可行性研究报告</option>
		<option value="14">资金申请报告</option>
		<option value="71">项目申请报告</option>
		<option value="76">初步设计</option>
		<option value="10">实施方案</option>
		<option value="14">规划</option>
		<option value="71">节能报告</option>
		<option value="76">课题研究</option>
		<option value="10">中（终）期验收</option>
		<option value="14">中（终）期评估</option>

	</select><br>
	<label>一级行业</label>
	<select id="fyStatus" class="ui_select01" onchange="setArea('fyStatus','fyStatus2');">
		<option value="">--请选择--</option>
		<option value="1">农业、林业</option>
		<option value="2">水利水电</option>
		<option value="3">电力</option>
		<option value="4">煤炭</option>
		<option value="5">石油天然气</option>
		<option value="6">公路</option>
		<option value="7">铁路、城市轨道</option>
		<option value="8">民航</option>
		<option value="9">水运</option>
		<option value="10">电子、信息工程</option>
		<option value="11">冶金</option>
		<option value="12">石化、化工、医药</option>
		<option value="13">核工业</option>
		<option value="14">机械</option>
		<option value="15">轻工、纺织</option>
		<option value="16">建材</option>
		<option value="17">建筑</option>
		<option value="18">市政公用工程</option>
		<option value="19">生态建设和环境工程</option>
		<option value="20">水文地质、工程测量、岩土工程</option>
		<option value="21">其他</option>


	</select><br>

	<label>二级行业</label>
	<select id="fyStatus2" class="ui_select01">
		<option value="">--请选择--</option>
	</select><br>
	<label>关键字</label> <input type="text" id="keyword" /><br>
	<script language="javascript">
		var area1 = new Array()
		area1[area1.length] = new Array("1", "农业、林业")
		area1[area1.length] = new Array("2", "水利水电")
		area1[area1.length] = new Array("3", "电力")
		area1[area1.length] = new Array("4", "煤炭")
		area1[area1.length] = new Array("5", "石油天然气")
		area1[area1.length] = new Array("6", "公路")
		area1[area1.length] = new Array("7", "铁路、城市轨道")
		area1[area1.length] = new Array("8", "民航")
		area1[area1.length] = new Array("9", "水运")
		area1[area1.length] = new Array("10", "电子、信息工程")
		area1[area1.length] = new Array("11", "冶金")
		area1[area1.length] = new Array("12", "石化、化工、医药")
		area1[area1.length] = new Array("13", "机核工业械")
		area1[area1.length] = new Array("14", "机械")
		area1[area1.length] = new Array("15", "轻工、纺织")
		area1[area1.length] = new Array("16", "建材")
		area1[area1.length] = new Array("17", "建筑")
		area1[area1.length] = new Array("18", "市政公用工程")
		area1[area1.length] = new Array("19", "生态建设和环境工程")
		area1[area1.length] = new Array("20", "水文地质、工程测量、岩土工程")
		area1[area1.length] = new Array("21", "其他")
		var area2 = new Array()
		area2[area2.length] = new Array("1", "1", "种植业")
		area2[area2.length] = new Array("1", "2", "畜牧业")
		area2[area2.length] = new Array("1", "3", "林业")
		area2[area2.length] = new Array("1", "4", "渔业")
		area2[area2.length] = new Array("1", "5", "副业")
		area2[area2.length] = new Array("2", "6", "防洪工程")
		area2[area2.length] = new Array("2", "7", "农田水利工程")
		area2[area2.length] = new Array("2", "8", "水力发电工程")
		area2[area2.length] = new Array("2", "9", "航道和港口工程")
		area2[area2.length] = new Array("2", "10", "城镇供水和排水工程")
		area2[area2.length] = new Array("2", "11", "水土保持工程和环境水利工程")
		area2[area2.length] = new Array("2", "12", "渔业水利工程")
		area2[area2.length] = new Array("2", "13", "海涂围垦工程")
		area2[area2.length] = new Array("2", "14", "综合利用水利工程")
		area2[area2.length] = new Array("3", "15", "火电")
		area2[area2.length] = new Array("3", "16", "水电")
		area2[area2.length] = new Array("3", "17", "核电")
		area2[area2.length] = new Array("3", "18", "新能源")
		area2[area2.length] = new Array("4", "19", "褐煤")
		area2[area2.length] = new Array("4", "20", "烟煤")
		area2[area2.length] = new Array("4", "21", "无烟煤")
		area2[area2.length] = new Array("4", "22", "半无烟煤")
		area2[area2.length] = new Array("5", "23", "勘探")
		area2[area2.length] = new Array("5", "24", "开发")
		area2[area2.length] = new Array("5", "25", "集输")
		area2[area2.length] = new Array("5", "26", "产品")
		area2[area2.length] = new Array("5", "27", "产品添加剂")
		area2[area2.length] = new Array("6", "28", "高速公路")
		area2[area2.length] = new Array("6", "29", "一级公路")
		area2[area2.length] = new Array("6", "30", "二级公路")
		area2[area2.length] = new Array("6", "31", "三级公路")
		area2[area2.length] = new Array("6", "32", "四级公路")
		area2[area2.length] = new Array("7", "33", "Ⅰ级铁路")
		area2[area2.length] = new Array("7", "34", "Ⅱ级铁路")
		area2[area2.length] = new Array("7", "35", "Ⅲ级铁路")
		area2[area2.length] = new Array("7", "36", "IV级铁路")
		area2[area2.length] = new Array("7", "37", "地铁")
		area2[area2.length] = new Array("7", "38", "轻轨")
		area2[area2.length] = new Array("7", "39", "有轨电车")
		area2[area2.length] = new Array("7", "40", "市郊铁路")
		area2[area2.length] = new Array("7", "41", "单轨交通")
		area2[area2.length] = new Array("7", "42", "自动导轨交通")
		area2[area2.length] = new Array("7", "43", "磁悬浮交通")
		area2[area2.length] = new Array("7", "44", "直线电机轨道交通")
		area2[area2.length] = new Array("8", "45", "公共航空运输")
		area2[area2.length] = new Array("8", "46", "通用航空")
		area2[area2.length] = new Array("9", "47", "沿海运输")
		area2[area2.length] = new Array("9", "48", "近海运输")
		area2[area2.length] = new Array("9", "49", "远洋运输")
		area2[area2.length] = new Array("9", "50", "远洋运输")
		area2[area2.length] = new Array("10", "51", "电子科学与技术")
		area2[area2.length] = new Array("10", "52", "计算机")
		area2[area2.length] = new Array("10", "53", "信息通讯工程")
		area2[area2.length] = new Array("10", "54", "网络空间安全")
		area2[area2.length] = new Array("11", "55", "黑色冶金")
		area2[area2.length] = new Array("11", "56", "有色冶金")
		area2[area2.length] = new Array("12", "57", "石化")
		area2[area2.length] = new Array("12", "58", "基础化工")
		area2[area2.length] = new Array("12", "59", "化学纤维")
		area2[area2.length] = new Array("12", "60", "医药")
		area2[area2.length] = new Array("13", "61", "无")
		area2[area2.length] = new Array("14", "62", "农业机械")
		area2[area2.length] = new Array("14", "63", "重型矿山机械")
		area2[area2.length] = new Array("14", "64", "工程机械")
		area2[area2.length] = new Array("14", "65", "石化通用机械")
		area2[area2.length] = new Array("14", "66", "电工机械")
		area2[area2.length] = new Array("14", "67", "机床")
		area2[area2.length] = new Array("14", "68", "汽车")
		area2[area2.length] = new Array("14", "69", "仪器仪表")
		area2[area2.length] = new Array("14", "70", "基础机械")
		area2[area2.length] = new Array("14", "71", "包装机械")
		area2[area2.length] = new Array("14", "72", "环保机械")
		area2[area2.length] = new Array("14", "73", "其他机械")
		area2[area2.length] = new Array("15", "74", "食品")
		area2[area2.length] = new Array("15", "75", "纺织")
		area2[area2.length] = new Array("15", "76", "家电")
		area2[area2.length] = new Array("15", "77", "造纸")
		area2[area2.length] = new Array("16", "78", "结构材料")
		area2[area2.length] = new Array("16", "79", "装饰材料")
		area2[area2.length] = new Array("17", "80", "居住建筑")
		area2[area2.length] = new Array("17", "81", "公共建筑")
		area2[area2.length] = new Array("17", "82", "工业建筑")
		area2[area2.length] = new Array("17", "83", "农业建筑")
		area2[area2.length] = new Array("18", "84", "城市道路及其设施")
		area2[area2.length] = new Array("18", "85", "城市桥涵及其设施")
		area2[area2.length] = new Array("18", "86", "城市排水设施")
		area2[area2.length] = new Array("18", "87", "城市防洪设施")
		area2[area2.length] = new Array("18", "88", "城市道路照明设施")
		area2[area2.length] = new Array("18", "89", "城市建设公用设施")
		area2[area2.length] = new Array("19", "90", "生态建设")
		area2[area2.length] = new Array("19", "91", "水污染防治")
		area2[area2.length] = new Array("19", "92", "大气污染防治")
		area2[area2.length] = new Array("19", "93", "固体废物处置")
		area2[area2.length] = new Array("19", "94", "噪音防治")
		area2[area2.length] = new Array("19", "95", "污染修复工程")
		area2[area2.length] = new Array("20", "96", "水文地质")
		area2[area2.length] = new Array("20", "97", "工程测量")
		area2[area2.length] = new Array("20", "98", "岩土工程")
		area2[area2.length] = new Array("21", "99", "无")

		function setArea(ID1, ID2) {
			var area1Obj = document.getElementById("fyStatus")
			var area2Obj = document.getElementById("fyStatus2")
			var i;
			var itemArray = null;
			if (area1Obj.value.length > 0) {
				itemArray = new Array();
				for (i = 0; i < area2.length; i++) {
					if (area2[i][0] == area1Obj.value) {
						itemArray[itemArray.length] = new
							Array(area2[i][1], area2[i][2]);
					}
				}
			}
			for (i = area2Obj.options.length; i >= 0; i--) {
				area2Obj.options[i] = null;
			}
			area2Obj.options[0] = new Option("--请选择--");
			area2Obj.options[0].value = "";

			if (itemArray != null) {
				for (i = 0; i < itemArray.length; i++) {
					area2Obj.options[i + 1] = new
						Option(itemArray[i][1]);
					if (itemArray[i][0] != null) {
						area2Obj.options[i].value = itemArray[i][0];
					}
				}
			}
		}


	</script>
	<input type="button" onclick="edit()" id="edit-button" value="确认" />
	<input type="button" onclick="close00()" id="closebutton" value="关闭" />
</body>
<script>
	
	show()
	function show() {
		var values = manyValues()
		const fs = require('fs')
		var person = []
		fs.readFile("./resources/app/time.json", function (err, data) {
			if (err) {
				return console.error(err)
			}

			person = JSON.parse(data.toString())
			$("#time").empty()
			var option0 = document.createElement("option");
			document.getElementById("time").appendChild(option0);
			option0.text = "--请选择--"

			for (var i = 0; i < person.length; i++) {
				var option = document.createElement("option");
				document.getElementById("time").appendChild(option);

				option.value = i + 1; //每个option的位置
				option.text = person[i].year;//每个Option的值


			}

			setSelectOption(document.getElementById("time"), values[1])



		}
		)


		$("#name").val(values[0])


		setSelectOption(document.getElementById("type"), values[2])
		setSelectOption(document.getElementById("fyStatus"), values[3])
		setArea('fyStatus', 'fyStatus2')
		setSelectOption(document.getElementById("fyStatus2"), values[4])
		$("#keyword").val(values[5])


	}

	function close00() {
		window.location.href = "house_list.html"

	}
	function setSelectOption(objSelect, targetValue) {
		if (objSelect) {
			var options = objSelect.options;
			if (options) {
				var len = options.length;
				for (var i = 0; i < len; i++) {
					if (options[i].text == targetValue) {
						options[i].defaultSelected = true;
						options[i].selected = true;
						return true;
					}
				}
			} /*else {
		   alert('missing element(s)!');
		  }*/
		} /*else {
		  alert('missing element(s)!');
		}*/
	}
	function edit() {

		var data = []
		var name = document.getElementById("name").value
		var time = document.getElementById("time").options[document.getElementById("time").selectedIndex].text
		if (time == "--请选择--") time = ""
		var type = document.getElementById("type").options[document.getElementById("type").selectedIndex].text
		if (type == "--请选择--") type = ""

		var area1 = document.getElementById("fyStatus").options[document.getElementById("fyStatus").selectedIndex].text
		if (area1 == "--请选择--") area1 = ""

		var area2 = document.getElementById("fyStatus2").options[document.getElementById("fyStatus2").selectedIndex].text
		if (area2 == "--请选择--") area2 = ""
		var keyword = document.getElementById("keyword").value

		data = [name, time, type, area1, area2, keyword]
		var a = require('./click.js')
		a.editJSON(data)
		alert("修改成功")
		window.location.href = "house_list.html"




	}
	function oneValues() {
		var result;
		var url = window.location.search; //获取url中"?"符后的字串  
		if (url.indexOf("?") != -1) {
			result = url.substr(url.indexOf("=") + 1);
		}
		return result;
	}

	function manyValues() {
		var url = window.location.search;
		var data = []

		if (url.indexOf("?") != -1) {

			var str = url.substr(1);
			strs = str.split("&");
			var key = new Array(strs.length);
			var value = new Array(strs.length);
			for (i = 0; i < strs.length; i++) {
				key[i] = strs[i].split("=")[0]
				value[i] = decodeURI(strs[i].split("=")[1]);

				data.push(value[i]);
				console.log(value[i])
			}
			return data
		}
	}


	function init() {
		var a = require("./click.js")



	}
</script>

</html>